package com.oracle.lingshangejia.activity.special;

import android.app.DatePickerDialog;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.RadioButton;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.google.gson.Gson;
import com.oracle.lingshangejia.Constant;
import com.oracle.lingshangejia.R;
import com.oracle.lingshangejia.adapter.special.CJ25ArchivesExtendableListAdapter;
import com.oracle.lingshangejia.bean.DataBean;
import com.oracle.lingshangejia.bean.HubbyBean;
import com.oracle.lingshangejia.bean.User;
import com.oracle.lingshangejia.dialog.LoadingViewDialog;
import com.oracle.lingshangejia.model.OkgoNetwork;
import com.oracle.lingshangejia.utils.MyLogger;
import com.oracle.lingshangejia.utils.MyToast;
import com.oracle.lingshangejia.utils.ObserverOnNext;
import com.oracle.lingshangejia.utils.RxUtils;

import org.json.JSONObject;

import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;

public class ChanJian25Activity extends AppCompatActivity {
    private ExpandableListView expandableListView;
    private CJ25ArchivesExtendableListAdapter archivesExtendableListAdapter;

    private static int[] childItems = {/*R.layout.cj25_activity_0, */R.layout.cj25_activity_1, R.layout.cj25_activity_2};
    // 用于存放折叠的视图
    private View[] viewss  = new View[childItems.length];

    private Spinner frequency;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cj25_add_archives_activity);
        initBasic();
        frequency = findViewById(R.id.archives_frequency);

        expandableListView = findViewById(R.id.expend_list);
        expandableListView.setGroupIndicator(null);
        String[] archivesStr = getResources().getStringArray(R.array.cj25_archives);
        archivesExtendableListAdapter = new CJ25ArchivesExtendableListAdapter(archivesStr);
        for(int i = 0; i < viewss.length; i++) {
            viewss[i] = LayoutInflater.from(expandableListView.getContext()).inflate(childItems[i], expandableListView, false);
        }
        archivesExtendableListAdapter.setConvertViews(viewss);
        expandableListView.setAdapter(archivesExtendableListAdapter);
        // 添加末尾提交按钮
        View foot = LayoutInflater.from(this).inflate(R.layout.archives_foot_submit, null);
        expandableListView.addFooterView(foot);

        expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
            @Override
            public void onGroupExpand(int groupPosition) {
                // 页面没加载时不折叠
                if(viewss == null)
                    return;
                int count = expandableListView.getExpandableListAdapter().getGroupCount();
                for (int i = 0; i < count; i++) {
                    if (i != groupPosition) {
                        expandableListView.collapseGroup(i);
                    }
                }

            }
        });
        frequency.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                //取得被选中的列表项的文字
                String frequency = parent.getItemAtPosition(position).toString();
                for(View v:viewss) {
                    System.out.println("视图：" + v);
                }
                CheckBox lifeway = viewss[1].findViewById(R.id.activity_guide_lifeway_1);
                CheckBox nutrition = viewss[1].findViewById(R.id.activity_guide_nutrition_2);
                CheckBox psychology = viewss[1].findViewById(R.id.activity_guide_psychology_3);
                CheckBox motion = viewss[1].findViewById(R.id.activity_guide_motion_4);
                CheckBox monitoring = viewss[1].findViewById(R.id.activity_guide_self_monitoring_5);
                CheckBox deliver = viewss[1].findViewById(R.id.activity_guide_deliver_6);
                CheckBox milk = viewss[1].findViewById(R.id.activity_guide_breast_milk_7);
                CheckBox other2 = viewss[1].findViewById(R.id.activity_guide_other_2);
                CheckBox other3 = viewss[1].findViewById(R.id.activity_guide_other_3);
                CheckBox other4 = viewss[1].findViewById(R.id.activity_guide_other_4);
                EditText text2 = viewss[1].findViewById(R.id.activity_guide_other_text_2);
                EditText text3 = viewss[1].findViewById(R.id.activity_guide_other_text_3);
                EditText text4 = viewss[1].findViewById(R.id.activity_guide_other_text_4);
                if("2 第2次产前随访服务记录".equals(frequency)) {
                    lifeway.setVisibility(View.VISIBLE);
                    nutrition.setVisibility(View.VISIBLE);
                    psychology.setVisibility(View.VISIBLE);
                    motion.setVisibility(View.VISIBLE);
                    other2.setVisibility(View.VISIBLE);
                    text2.setVisibility(View.VISIBLE);

                    monitoring.setVisibility(View.GONE);
                    deliver.setVisibility(View.GONE);
                    milk.setVisibility(View.GONE);
                    other3.setVisibility(View.GONE);
                    other4.setVisibility(View.GONE);
                    text3.setVisibility(View.GONE);
                    text4.setVisibility(View.GONE);
                } else if ("3 第3次产前随访服务记录".equals(frequency)){
                    lifeway.setVisibility(View.VISIBLE);
                    nutrition.setVisibility(View.VISIBLE);
                    psychology.setVisibility(View.VISIBLE);
                    motion.setVisibility(View.VISIBLE);
                    monitoring.setVisibility(View.VISIBLE);
                    deliver.setVisibility(View.VISIBLE);
                    other3.setVisibility(View.VISIBLE);
                    text3.setVisibility(View.VISIBLE);


                    milk.setVisibility(View.GONE);
                    other2.setVisibility(View.GONE);
                    other4.setVisibility(View.GONE);
                    text2.setVisibility(View.GONE);
                    text4.setVisibility(View.GONE);
                } else if ("4 第4次产前随访服务记录".equals(frequency)){
                    lifeway.setVisibility(View.VISIBLE);
                    nutrition.setVisibility(View.VISIBLE);
                    psychology.setVisibility(View.VISIBLE);
                    motion.setVisibility(View.VISIBLE);
                    monitoring.setVisibility(View.VISIBLE);
                    deliver.setVisibility(View.VISIBLE);
                    milk.setVisibility(View.VISIBLE);
                    other4.setVisibility(View.VISIBLE);
                    text4.setVisibility(View.VISIBLE);


                    other2.setVisibility(View.GONE);
                    other3.setVisibility(View.GONE);
                    text2.setVisibility(View.GONE);
                    text3.setVisibility(View.GONE);
                } else if ("5 第5次产前随访服务记录".equals(frequency)){
                    lifeway.setVisibility(View.VISIBLE);
                    nutrition.setVisibility(View.VISIBLE);
                    psychology.setVisibility(View.VISIBLE);
                    motion.setVisibility(View.VISIBLE);
                    monitoring.setVisibility(View.VISIBLE);
                    deliver.setVisibility(View.VISIBLE);
                    milk.setVisibility(View.VISIBLE);
                    other4.setVisibility(View.VISIBLE);
                    text4.setVisibility(View.VISIBLE);

                    other2.setVisibility(View.GONE);
                    other3.setVisibility(View.GONE);
                    text2.setVisibility(View.GONE);
                    text3.setVisibility(View.GONE);
                }
                // 获取数据后只留第一个展开，其余关闭
                int count = expandableListView.getExpandableListAdapter().getGroupCount();
                for (int i = 0; i < count; i++) {
                    if(i == 0) {
                        expandableListView.expandGroup(i);
                    } else {
                        expandableListView.collapseGroup(i);
                    }
                }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {

            }
        });
        // 页面加载完展开所有数据，用于获取视图数据
        int count = expandableListView.getExpandableListAdapter().getGroupCount();
        for (int i = 0; i < count; i++) {
            expandableListView.expandGroup(i);
        }
        expandableListView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
            @Override
            public void onGroupCollapse(int groupPosition) {
                View[] views = ((CJ25ArchivesExtendableListAdapter) expandableListView.getExpandableListAdapter()).getConvertViews();
                View view = views[groupPosition];
                if (view == null) {
                    return;
                }

                switch (groupPosition) {
                  /*  case 1:
                       getBasicInfoValues();
                        break;*/
                    case 0:
                        getEducationAndProfessionalAndMarriageAndPayValues(view);
                        break;
                    case 1:
                        getAllergyAndExposedValues(view);
                        break;

                }


            }
        });

        expandableListView.expandGroup(0);

    }


    /**
     * 检查用户名、身份证号和本人联系电话是否正确填写
     *
     * @return 数据不正确返回true，正确返回false
     */
    private boolean checkBasicInfoIsError() {
        Map<String, String> basicInforValues = getBasicInfoValues();
        String xm = (String) basicInforValues.get("xm");

        // 姓名非空验证
        if (xm == null || xm.length() == 0) {
            Toast.makeText(getApplicationContext(), "姓名必须填写", Toast.LENGTH_SHORT).show();
            return true;
        }
        return false;
    }


    private Map<String, String> getBasicInfoValues() {
        View[] views = ((CJ25ArchivesExtendableListAdapter) expandableListView.getExpandableListAdapter()).getConvertViews();
        View view = views[0];
        Map<String, String> params = new HashMap<>();
        // 姓名
        String username = "";
        username = ((EditText) view.findViewById(R.id.activity_username)).getText().toString().trim();
        params.put("xm", username);//姓名
        return params;
    }

    /**
     * 第二页
     */
    private Map<String, String> getEducationAndProfessionalAndMarriageAndPayValues(View view) {
        Map<String, String> params = new HashMap<>();
        // 随访日期
        String followupdate = "";
        //孕周
        String gestationalage = "";
        //主诉
        String chiefcomplaint = "";
        //体重
        String weight = "";
        //宫底高度
        String height = "";
        // 腹围
        String circumference = "";
        //胎位
        String fetalposition = "";
        //胎心率
        String fetalheartrate = "";
        //血压
        String bloodpressure = "";
        //血压
        String bloodpressure_2 = "";
        //血红蛋白
        String hemoglobin = "";
        //尿蛋白
        String urineprotein = "";
        //其他辅助检查
        String otherancillaryexaminations = "";


      //  followupdate = ((TextView) view.findViewById(R.id.archives_date_2)).getText().toString().trim();
        gestationalage = ((EditText) view.findViewById(R.id.activity_gestationalWeek_2)).getText().toString().trim();
        chiefcomplaint = ((EditText) view.findViewById(R.id.activity_mainsuit_2)).getText().toString().trim();
        weight= ((EditText) view.findViewById(R.id.activity_weight_2)).getText().toString().trim();
        height = ((EditText) view.findViewById(R.id.activity_height_of_fundus_2)).getText().toString().trim();
        circumference = ((EditText) view.findViewById(R.id.activity_abdominal_girth_2)).getText().toString().trim();
        fetalposition = ((EditText) view.findViewById(R.id.activity_position_of_the_fetus_2)).getText().toString().trim();
        fetalheartrate = ((EditText) view.findViewById(R.id.activity_FHR_2)).getText().toString().trim();
        bloodpressure = ((EditText) view.findViewById(R.id.activity_blood_pressure_zuo_2)).getText().toString().trim();
        bloodpressure_2 = ((EditText) view.findViewById(R.id.activity_blood_pressure_you_2)).getText().toString().trim();
        hemoglobin = ((EditText) view.findViewById(R.id.activity_hemoglobin_2)).getText().toString().trim();
        urineprotein = ((EditText) view.findViewById(R.id.activity_urinary_protein_2)).getText().toString().trim();
        otherancillaryexaminations = ((EditText) view.findViewById(R.id.activity_other_examinations_2)).getText().toString().trim();

      //  params.put("sfrq", followupdate);
        params.put("yz", gestationalage);//孕周
        params.put("zs", chiefcomplaint);//主诉
        params.put("tz", weight);//体重
        params.put("ckjcGdgd", height);//宫底高度
        params.put("ckjcFw", circumference);//腹围
        params.put("ckjcTw", fetalposition);//胎位
        params.put("ckjcTxl", fetalheartrate);//胎心率
        params.put("xySsl", bloodpressure);///收缩
        params.put("xySzl", bloodpressure_2);//舒张
        params.put("xgdb", hemoglobin);//血红蛋白
        params.put("ndb", urineprotein);//尿蛋白
        params.put("qtfzjc", otherancillaryexaminations);//其他辅助检查
        mValues.putAll(params);
        return params;
    }

    /**
     * 第三页
     */
    private Map<String, String> getAllergyAndExposedValues(View view) {
        Map<String, String> params = new HashMap<>();
        //分类
        String classification = "";
        //分类异常
        String classification_1 = "";
        if (((RadioButton) view.findViewById(R.id.activity_classify_noAbnormalities_2)).isChecked()) {
            //national = "1 汉族";
            classification = "1 ";
        } else {
            //national = ((EditText) views[0].findViewById(R.id.archives_national_other)).getText().toString().trim();
            classification = "2 ";
        }
        classification_1 = ((EditText) view.findViewById(R.id.activity_classify_Abnormalities_Text_2)).getText().toString().trim();

        params.put("fl", classification);//分类
        params.put("flyc", classification_1);//分类异常
        //指导
        String abnormal = "";
        //指导其他
        String noabnormal = "";
        View[] payViews = getViews(view.findViewById(R.id.activity_guide_2));
        for (int i = 0; i < payViews.length; i++) {
            if (payViews[i] instanceof CheckBox) {
                CheckBox cb = (CheckBox) payViews[i];
                if (cb.isChecked()) {
                    String s = cb.getText().toString().trim();
                    s = s.substring(0, s.indexOf(" "));
                    abnormal += s;
                    abnormal+= ",";
                }
            }
        }
        if (abnormal.length() != 0) {
            abnormal = abnormal.substring(0, abnormal.length() - 1);
        }
        noabnormal = ((EditText) view.findViewById(R.id.activity_guide_other_text_2)).getText().toString().trim();
        params.put("zd", abnormal);//指导
        params.put("zdQt", noabnormal);//其他
        //转诊
        String Referral = "";
        //转诊原因
        String Referral_reason = "";
        if (((RadioButton) view.findViewById(R.id.activity_TransferTreatment_no_2)).isChecked()) {
            //national = "1 汉族";
            Referral = "1";
        } else {
            //national = ((EditText) views[0].findViewById(R.id.archives_national_other)).getText().toString().trim();
            Referral = "2";
        }
        Referral_reason = ((EditText) view.findViewById(R.id.activity_TransferTreatment_yes_reason_2)).getText().toString().trim();

        params.put("zzjy", Referral);//
        params.put("zzyy", Referral_reason);//
        //转诊机构
        String Zhuanzhenjg = "";
        //转诊科室
        String Zhuanzhenks = "";
        Zhuanzhenjg = ((EditText) view.findViewById(R.id.activity_TransferTreatment_yes_Institutional_2)).getText().toString().trim();
        Zhuanzhenks = ((EditText) view.findViewById(R.id.activity_TransferTreatment_yes_Institutional_3)).getText().toString().trim();
        params.put("zzjg", Zhuanzhenjg);
        params.put("zzks", Zhuanzhenks);
        String suifangysqm;
        suifangysqm = ((EditText) view.findViewById(R.id.activity_autograph)).getText().toString().trim();
        params.put("sfysqm", suifangysqm);
        String nextsuifangriqi;
        nextsuifangriqi = ((TextView) view.findViewById(R.id.activity_NextFollowupDate_2)).getText().toString().trim();
        params.put("scsfsj", nextsuifangriqi);
        //5其他
        String Qita5= "";
        //7其他
        String Qita7 = "";
        //8其他
        String Qita8 = "";
        Qita5 = ((EditText) view.findViewById(R.id.activity_guide_other_text_2)).getText().toString().trim();
        Qita7 = ((EditText) view.findViewById(R.id.activity_guide_other_text_3)).getText().toString().trim();
        Qita8 = ((EditText) view.findViewById(R.id.activity_guide_other_text_4)).getText().toString().trim();
    /*    params.put("fv_qt", Qita5);
        params.put("se_qt", Qita7);
        params.put("ei_qt", Qita8);*/
         mValues.putAll(params);
         MyLogger.i((new JSONObject(params).toString()));
        return params;
    }



    /**
     * 分类点击事件处理
     */
    public void changeClassifyEnableEdit_2(View view) {
        EditText ed = findViewById(R.id.activity_classify_Abnormalities_Text_2);
        RadioButton rb = (RadioButton) view;
        if (view.getId() == R.id.activity_classify_noAbnormalities_2) {
            ed.setText("");
            ed.setEnabled(false);
        } else if (rb.isChecked()) {
            ed.setEnabled(true);
            ed.setFocusable(true);
            ed.setFocusableInTouchMode(true);
            ed.requestFocus();
        }
    }




    /**
     * 指导点击事件
     */

    public void onGuidanceClick_2(View view) {
        CheckBox cb = (CheckBox) view;
        EditText et = findViewById(R.id.activity_guide_other_text_2);
        if (cb.isChecked()) {
            et.setEnabled(true);
            et.setFocusable(true);
            et.setFocusableInTouchMode(true);
            et.requestFocus();
        } else {
            et.setText("");
            et.setEnabled(false);
        }
    }
    public void onGuidanceClick_3(View view) {
        CheckBox cb = (CheckBox) view;
        EditText et = findViewById(R.id.activity_guide_other_text_3);
        if (cb.isChecked()) {
            et.setEnabled(true);
            et.setFocusable(true);
            et.setFocusableInTouchMode(true);
            et.requestFocus();
        } else {
            et.setText("");
            et.setEnabled(false);
        }
    }
    public void onGuidanceClick_4(View view) {
        CheckBox cb = (CheckBox) view;
        EditText et = findViewById(R.id.activity_guide_other_text_4);
        if (cb.isChecked()) {
            et.setEnabled(true);
            et.setFocusable(true);
            et.setFocusableInTouchMode(true);
            et.requestFocus();
        } else {
            et.setText("");
            et.setEnabled(false);
        }
    }

    /**
     * 转诊点击事件处理
     */
    public void changeTransferTreatmentEnableEdit_2(View view) {
        EditText ed1 = findViewById(R.id.activity_TransferTreatment_yes_reason_2);
        EditText ed2 = findViewById(R.id.activity_TransferTreatment_yes_Institutional_2);
        EditText ed3 = findViewById(R.id.activity_TransferTreatment_yes_Institutional_3);

        RadioButton rb = (RadioButton) view;
        if (view.getId() == R.id.activity_TransferTreatment_no_2) {
            ed1.setText("");
            ed1.setEnabled(false);
            ed2.setText("");
            ed2.setEnabled(false);
            ed3.setText("");
            ed3.setEnabled(false);
        } else if (rb.isChecked()) {
            ed1.setEnabled(true);
            ed1.setFocusable(true);
            ed1.setFocusableInTouchMode(true);
            ed1.requestFocus();
            ed2.setEnabled(true);
            ed2.setFocusable(true);
            ed2.setFocusableInTouchMode(true);
            ed2.requestFocus();
            ed3.setEnabled(true);
            ed3.setFocusable(true);
            ed3.setFocusableInTouchMode(true);
            ed3.requestFocus();
        }
    }

    /**
     * (随访/督促）日期
     */
    private Calendar calendar;
    private DatePickerDialog dialog;

    public void onTimeViewClick_2(final View v) {
        calendar = Calendar.getInstance();
        dialog = new DatePickerDialog(ChanJian25Activity.this,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        TextView tv = (TextView) v;
                        tv.setText(year + "-" + (monthOfYear < 10 ? ("0" + monthOfYear) : monthOfYear) + "-"
                                + (dayOfMonth < 10 ? ("0" + dayOfMonth) : dayOfMonth));
                    }
                }, calendar.get(Calendar.YEAR), calendar
                .get(Calendar.MONTH), calendar
                .get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }

    /**
     * 下次随访日期
     */

    public void onNextFollowupDateClick_2(final View v) {
        calendar = Calendar.getInstance();
        dialog = new DatePickerDialog(ChanJian25Activity.this,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year,
                                          int monthOfYear, int dayOfMonth) {
                        TextView tv = (TextView) v;
                        String month;
                        String day;
                        if (monthOfYear <9){
                            month = "0"+(monthOfYear+1);
                        }else {
                            month = ""+(monthOfYear+1);
                        }
                        if (dayOfMonth <10){
                            day = "0"+dayOfMonth;
                        }else {
                            day = dayOfMonth + "";
                        }
                        tv.setText(year + "-" + month  + "-" + day);
                    }
                }, calendar.get(Calendar.YEAR), calendar
                .get(Calendar.MONTH), calendar
                .get(Calendar.DAY_OF_MONTH));
        dialog.show();
    }




    /**
     * Toolbar的事件---返回
     */
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            finish();
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * 获取子视图
     */
    private View[] views;

    private View[] getViews(View view) {
        views = new View[0];
        parseView(view);
        return views;
    }

    private void parseView(View view) {
        if (view instanceof ViewGroup) {
            ViewGroup vg = (ViewGroup) view;
            for (int i = 0; i < vg.getChildCount(); i++) {
                View v = vg.getChildAt(i);
                parseView(v);
            }
        } else {
            views = Arrays.copyOf(views, views.length + 1);
            views[views.length - 1] = view;
        }
    }

    /**
     * 提交数据
     */
    public void onClickSubmit(View view) {
        showLoading();
        int count = expandableListView.getExpandableListAdapter().getGroupCount();
        for (int i = 0; i < count; i++) {
            expandableListView.collapseGroup(i);
        }
        Observable.create(new ObservableOnSubscribe<DataBean>() {
            @Override
            public void subscribe(ObservableEmitter<DataBean> emitter) throws Exception {
                JSONObject jsonObject = new JSONObject(mValues);
                MyLogger.i(jsonObject.toString());
                String json = OkgoNetwork.post(url,jsonObject.toString());
                MyLogger.i(json);
                Gson gson = new Gson();
                emitter.onNext(gson.fromJson(json, DataBean.class));

            }
        }).compose(RxUtils.io_main()).subscribe(new ObserverOnNext<DataBean>() {
            @Override
            public void onNext(DataBean dataBean) {
                if (dataBean.getCode()==0){
                    MyToast.show("提交成功");
                    finish();
                }else {
                    MyToast.show(dataBean.getMsg());
                }
                dismissLoading();

            }
        });

    }


    private HubbyBean mBean;
    //新
    private Map<Object,Object> mValues = new HashMap<>();
    private  String url = Constant.baseurl+"online/zxdaycf/saveEdw";
    private LoadingViewDialog mLoadingView;
    //整合专项  基础 修改
    private void initBasic(){
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        Toolbar toolbar = (Toolbar)findViewById(com.oracle.children.R.id.toolbar);
        toolbar.setTitle("");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mValues.put("token", User.getToken());
        mValues.put("jmId",getIntent().getIntExtra("jmid", 0) );
        mValues.put("userId", User.getUserId());//社区医生id;
        mValues.put("mark", 1);
        //随访id
        int id = getIntent().getIntExtra("id", 0);
        if (id !=0){
            mValues.put("sfjlId", id);
            mValues.put("id", id);
        }
        //获取丈夫信息
        //getParents();
    }

    private void getParents(){
        Observable.create(new ObservableOnSubscribe<HubbyBean>() {
            @Override
            public void subscribe(ObservableEmitter<HubbyBean> emitter) throws Exception {
                Map<Object, Object> values = new HashMap<>();
                values.put("grjbxxId",getIntent().getIntExtra("jmid", 0));
                values.put("mark", 1);
                values.put("token", User.getToken());
                JSONObject jsonObject = new JSONObject(values);
                MyLogger.i(jsonObject.toString()); //获取丈夫信息
                String json = OkgoNetwork.post(Constant.baseurl+"online/zxdaycf/checkZf",jsonObject.toString());
                MyLogger.i(json);
                Gson gson = new Gson();
                emitter.onNext(gson.fromJson(json, HubbyBean.class));
            }
        }).compose(RxUtils.io_main()).subscribe(new ObserverOnNext<HubbyBean>() {
            @Override
            public void onNext(HubbyBean parentsBean) {
                if (parentsBean.getData()!= null){
                    mBean = parentsBean;
                }

            }
        });

    }



    public void showLoading(){
        mLoadingView = new LoadingViewDialog();
        mLoadingView.show(getSupportFragmentManager(),"" );
    }
    public void dismissLoading(){
        if (mLoadingView != null){
            mLoadingView.dismiss();
        }

    }







}
